Skip to content

(chore) Address unreachable service check assertions in cloud_foundry_api oauth error tests#24282

Open
mwdd146980 wants to merge 1 commit into
masterfrom
mwdd146980/cloud-foundry-api-dead-service-check-assertions
Open

(chore) Address unreachable service check assertions in cloud_foundry_api oauth error tests#24282
mwdd146980 wants to merge 1 commit into
masterfrom
mwdd146980/cloud-foundry-api-dead-service-check-assertions

Conversation

@mwdd146980

@mwdd146980 mwdd146980 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Restructures test_get_oauth_token_errors in cloud_foundry_api so its aggregator.assert_service_check(...) calls actually execute.

Motivation

Each error block wrapped both the raising call and the assertions after it in the same pytest.raises(...) context:

with mock.patch.object(check, "_http") as http_mock, pytest.raises(RequestException):
    http_mock.get.side_effect = RequestException()
    check.get_oauth_token()
    aggregator.assert_service_check(...)  # never runs
    aggregator.reset()                     # never runs

check.get_oauth_token() raises before reaching the lines after it, so pytest.raises catches the exception and exits the with block immediately, which means that the assertion and reset are dead code. The fix nests pytest.raises around only the raising call, so the assertions run after the exception is caught, once get_oauth_token has already emitted its CRITICAL service check.

This is a pre-existing test bug, called out separately from the W1b cloud_foundry_api catch-widening plan as explicitly out of scope there. It's unrelated to the httpx migration, so this PR targets master directly.

Verification

  • Proved the assertions were dead code before fixing: swapped the expected status to OK (a value production never emits on this path) and confirmed the test still passed.
  • Applied the fix, re-ran, and confirmed the test passes for the right reason.
  • Re-ran the same OK-swap mutation against the fixed test and confirmed it now correctly fails, then reverted to the correct CRITICAL assertion.
  • ddev --no-interactive test cloud_foundry_api: all 23 tests pass.
  • ddev test -fs cloud_foundry_api: formatting and lint clean.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

…rror tests

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Validate repository | Run Validations / Validate   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 96.85%

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a7f0fff | Docs | Datadog PR Page | Give us feedback!

@mwdd146980 mwdd146980 added the qa/skip-qa Automatically skip this PR for the next QA label Jul 1, 2026
@mwdd146980 mwdd146980 marked this pull request as ready for review July 1, 2026 01:25
@mwdd146980 mwdd146980 requested a review from a team as a code owner July 1, 2026 01:25
@dd-octo-sts

dd-octo-sts Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@mwdd146980 mwdd146980 changed the title Fix unreachable service check assertions in cloud_foundry_api oauth error tests (chore) Address unreachable service check assertions in cloud_foundry_api oauth error tests Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant